cmake_minimum_required(VERSION 3.10)
project(C)
set(CMAKE_C_STANDARD 11)

# 项目路径设置
set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_ROOT_DIR}/bin)
set(RESOURCES_DIR ${PROJECT_ROOT_DIR}/resources)

# 头文件路径
include_directories(
    ${PROJECT_ROOT_DIR}/include
    /usr/include                # SQLite3 的头文件路径（系统默认）
)

# 源码路径
set(SRC_DIR ${PROJECT_ROOT_DIR}/src)

# 查找线程库
find_package(Threads REQUIRED)

# 可执行文件
add_executable(main
    ${SRC_DIR}/cJSON.c
    ${SRC_DIR}/database.c
    ${SRC_DIR}/dp_table.c
    ${SRC_DIR}/dp_pthread.c
    ${SRC_DIR}/main.c
    ${SRC_DIR}/mqtt_json.c
    ${SRC_DIR}/msg_queue_peer.c
    ${SRC_DIR}/shmem.c
)

# 链接库
target_link_libraries(main
    Threads::Threads
    sqlite3          # 手动链接 SQLite3（系统默认路径）
    m
    paho-mqtt3c      # MQTT 库，确保系统或路径中存在
)